package com.qfedu.stussm.controller;

import com.qfedu.stussm.entity.Sreward;
import com.qfedu.stussm.entity.Student;
import com.qfedu.stussm.service.intf.SrewardService;
import com.qfedu.stussm.service.intf.StudentService;
import com.qfedu.stussm.vo.PageBeanVo;
import com.qfedu.stussm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/api/sreward/")
public class SrewardController {
    @Autowired
    private SrewardService service;

    //查询
    @GetMapping("all.do")
    @ResponseBody
    public List<PageBeanVo> all(){
        return service.selectAll();
    }
    @GetMapping("page.do")
    @ResponseBody
    public PageBeanVo page(String stu_Aname, int page, int limit){
        System.out.println(stu_Aname);
        return service.queryPage(stu_Aname,page, limit);
    }
    //添加
    @PostMapping("save.do")
    public String save(Sreward sreward){
        service.add(sreward);
        System.out.println(sreward);
        return "redirect:/srewardlist.html";
    }
    //修改
    @PostMapping("update.do")
    @ResponseBody
    public R update(Sreward sreward){
        return service.update(sreward);
    }
    //删除
    @PostMapping("del.do")
    @ResponseBody
    public R del(int id){
        return service.del(id);
    }
}
